$(function() {
    //判断是否登录
    /*  var userInfo = sessionStorage['users'];
     if (userInfo == null) {
         alert('请先登录！');
         location.href = 'login.html';
         $('#userName').html("未登录");
         $('#login').html('登录/注册')
     } else {
         var user = JSON.parse(sessionStorage['users'])
         $('#userName').html(user[0].Name)
         $('#login').html('退出登录')
     } */
    //将发布内容保存到本地
    releaseWant();
})

//将发布内容保存到本地
function releaseWant() {
    var productName = document.querySelector('.productName').querySelector('input');
    var wantPrice = document.querySelector('.wantPrice').querySelector('input');
    var want_details = document.querySelector('.want_details').querySelector('textarea');
    var tel = document.querySelector('.tel').querySelector('input');

    var submitBtn = document.querySelector('.submit');

    var releaseWant = JSON.parse(localStorage.getItem('releaseWant'));
    submitBtn.onclick = function() {
        releaseWant.push({
            "productName": productName.value,
            "wantPrice": wantPrice.value,
            "want_details": want_details.value,
            "tel": tel.value
        })
        localStorage['releaseWant'] = JSON.stringify(releaseWant);
    }
}